﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using ZkSurvey.DAL.SurveyMgr;
using ZkSurvey.Common.SurveyMgr;

namespace ZkSurvey.BLL.SurveyMgr
{
    public class OptionBl
    {
        public void CreateOption(Option option)
        {
            OptionDa.InsertOption(option);
        }

        public List<Option> GetOptionList(int quesId)
        {
            return OptionDa.GetOptionList(quesId);
        }

        public void DeleteOption(int id)
        {
            OptionDa.Delete(id);
        }

        public int GetMaxSort(int quesId)
        {
            List<Option> options = OptionDa.GetOptionList(quesId);
            if (options.Count == 0)
                return 0;
            return options.Max(opt => opt.Sort);
        }

        public int GetNextSort(int quesId)
        {
            return GetMaxSort(quesId) + 1;
        }
    }
}
